package com.panfeng.xcloud.boss.provider.assets.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.panfeng.xcloud.boss.provider.assets.dto.request.QueryWalletAssetsPageReqDTO;
import com.panfeng.xcloud.boss.provider.assets.dto.response.QueryWalletAssetsPageRespDTO;
import com.panfeng.xcloud.boss.provider.assets.service.IWalletAssetsService;
import com.panfeng.xcloud.boss.provider.assets.web.vo.request.QueryWalletAssetsPageReqVO;
import com.panfeng.xcloud.boss.provider.assets.web.vo.response.QueryWalletAssetsPageRespVO;
import com.panfeng.xcloud.common.core.page.PageResponse;
import com.panfeng.xcloud.common.core.utils.ConvertUtils;
import com.panfeng.xcloud.common.core.web.vo.PageResponseVO;
import com.panfeng.xcloud.common.core.web.vo.ResponseVO;
import com.panfeng.xcloud.common.security.annotation.MethodValidate;
import com.panfeng.xcloud.common.security.annotation.NotNeedAccess;
import com.panfeng.xcloud.common.security.web.support.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 相关资产模块
 *
 * @author xiaobo
 * @version 1.0
 * @since 2021-03-23
 */
//@ApiIgnore
@RestController
@RequestMapping("assets/walletAssets")
@Api(tags = {"相关资产模块"})
@Slf4j
public class WalletAssetsController extends BaseController {

    @Autowired
    private IWalletAssetsService iWalletAssetsService;

    /**
     * 查询相关资产
     *
     * @param queryWalletAssetsPageReqVO
     * @param bindingResult
     * @return
     */
    @NotNeedAccess
    @MethodValidate
    @PostMapping(value = "/queryWalletAssets", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询相关资产(肖博)", httpMethod = "POST", notes = "查询相关资产(肖博)")
    public ResponseVO<PageResponseVO<QueryWalletAssetsPageRespVO>> queryWalletAssets(@RequestBody @Valid QueryWalletAssetsPageReqVO queryWalletAssetsPageReqVO, BindingResult bindingResult) {
        logger.info(">>>> 当前queryWalletAssets请求参数：{} <<<", (null != queryWalletAssetsPageReqVO ? JSONObject.toJSONString(queryWalletAssetsPageReqVO) : ""));
        QueryWalletAssetsPageReqDTO queryWalletAssetsPageReqDTO = ConvertUtils.convert(queryWalletAssetsPageReqVO, QueryWalletAssetsPageReqDTO.class);
        PageResponse<QueryWalletAssetsPageRespDTO> pageDTO = iWalletAssetsService.queryWalletAssets(queryWalletAssetsPageReqDTO);
        PageResponseVO<QueryWalletAssetsPageRespVO> pageVO = ConvertUtils.convertPage(pageDTO, QueryWalletAssetsPageRespVO.class);
        logger.info(">>>> 当前queryWalletAssets响应内容：{} <<<", (null != pageVO ? JSONObject.toJSONString(pageVO) : ""));
        return ResponseVO.with(pageVO);
    }

}
